package com.lfy.aop.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@AllArgsConstructor
@Getter
public enum FileMagicTypeEnum {
        EXE_OR_DLL("EXE", "4D5A"),
        PHP("PHP", "7B"),
        SO("SO", "7F454C46"),
        ;
        public final String extension;
        public final String hexHeader;
        private static Map<String, String> map;
        static {
                map = Stream.of(FileMagicTypeEnum.values())
                        .collect(Collectors.toMap(FileMagicTypeEnum::getHexHeader, FileMagicTypeEnum::getExtension));
        }

        public static String getExtension(String header) {
                return map.get(header);
        }

}
